
import baseRequest from '../utils/requset'
import baseIndexRequest from '../utils/requset'
// import qs from 'qs'


// const queryString = '?name=John&age=30';
// const parsedObj = qs.parse(queryString.slice(1)); // 去掉开头的 '?'
// console.log(parsedObj);
// // 输出: { name: 'John', age: 30 }


// 通过id得到商品详细信息
export function queryProductByIdApi (data) {
    return baseIndexRequest.baseIndexRequest('api/product/queryProductById', 'get', data)
}


// 商品列表
export function getProductListApi(data) {
    return baseRequest.baseRequest(
        'api/product/pagingQuery', 
        'get', 
        data
    )
}

export function queryInfoByIdApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/category/queryById', 
        'post', 
        JSON.stringify(data))
}

// 同级
export function queryByIdSameLevelApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/category/queryByIdSameLevel', 
        'post', 
        JSON.stringify(data))
}

// 根据上级分类ID获取所属的分类信息
export function queryListByPidApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/category/queryByPid', 
        'post', 
        JSON.stringify(data))
}

// 获取惊喜顶部分类列表
export function categorySurpriseApi() {
    return baseIndexRequest.baseIndexRequest(
        'api/category/surprise', 
        'get')
}

// // 优惠券
// export function couponPagingQueryApi(data) {
//     return baseIndexRequest.baseIndexRequest(
//         'api/coupon/pagingQuery', 
//         'post', 
//         JSON.stringify(data))
// }

// 商品对应的优惠券列表 /api/coupon/product/list
export function couponProductListApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/coupon/product/list',
        'get',
        data
    )
}
// 用户领取的优惠券详情 /api/coupon/user/detail/list
export function couponUserDetailListApi(data) {
    return baseRequest.baseRequest(
        'api/coupon/user/detail/list',
        'get',
        data
    )
}

// 用户领取优惠券 /api/coupon/user/get get
export function couponUserGetApi(data) {
    return baseRequest.baseRequest(
        'api/coupon/user/get',
        'get',
        data
    )
}

// // 领取优惠券  需要用户信息  登录
// export function insertCouponApi(data) {
//     return baseRequest.baseRequest(
//         'api/couponUser/insert', 
//         'post', 
//         JSON.stringify(data))
// }

// 所有一级分类
export function allCategoryFirstLevelApi() {
    return baseIndexRequest.baseIndexRequest(
        'api/category/allCategory',
        'get')
}
// 根据分类id查询商品 /api/category/infoByCateId/{id}
export function queryInfoByCateIdApi(id) {
    return baseIndexRequest.baseIndexRequest(
        'api/category/infoByCateId/' + id,
        'get')
}
// 一二级分类树  在购物车凑单跳转的页面/api/category/categoryTree/{bannerType}
export function queryCategoryTreeApi(bannerType) {
    return baseIndexRequest.baseIndexRequest(
        'api/category/categoryTree/' + bannerType,
        'get')
}



// 根据三级分类id查询 商品列表 api/product/pagingByCategoryId   get 
export function pagingByCategoryIdApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/product/pagingByCategoryId',
        'get',
        data
    )
}


// 满减  商品对应的满减活动 /api/leFullDiscount/product/list get
export function getLeFullDiscountProductListApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/leFullDiscount/product/list',
        'get',
        data
    )
}

// 满减凑单活动--对应的商品列表 /api/leFullDiscount/product/getAddProduct get
export function getLeFullDiscountProductGetAddProductApi(data) {
    return baseIndexRequest.baseIndexRequest(
        'api/leFullDiscount/product/getAddProduct',
        'get',
        data
    )
}